﻿using SimpleConnection_UDP_WIN.extension_class.utils;
using SimpleConnection_UDP_WIN.interface_class;
using SimpleConnection_UDP_WIN.utils.UDP;
using System;
using System.Windows.Forms;

namespace SimpleConnection_UDP_WIN.extension_class.hidden
{
    internal class ExitClass : PluginAbstractClass, PluginBaseInfoInterface
    {


        //传入命令的关键协议名
        public const string Protocol = "exit";

        public ExitClass()
        {
        }

        public ExitClass(string message, string ip, int port) : base(message, ip, port)
        {
            this.message = message;
            this.ip = ip;
            this.port = port;

        }

        public string Name => "关闭程序类";
        public string Describe => "通过这个类来结束本程序";
        public string Version => "1.0.0";
        public string Help => "示例:exit://0";

        /// <summary>
        /// 主要执行方法
        /// </summary>
        public void exec()
        {

            if (MessageParsingClass.isAdmin(message))
            {
                if (MessageParsingClass.getText(message).Equals("0"))
                {
                    new UdpTool(ip, 8871).SendMessage(GetType().Name, "已彻底关闭程序");
                    Environment.Exit(0);
                   // Application.Exit(); // 终止程序
                }
               
            }

        }

    }
}
